package model

import "gorm.io/gorm"

type Comment struct {
	gorm.Model
	UserId  int    `gorm:"type:int" json:"userId"`
	VideoId int    `gorm:"type:int" json:"videoId"`
	Content string `gorm:"type:varchar(30)" json:"content"`
	Pid     int    `gorm:"type:int" json:"pid"`
}

func (c *Comment) AddComment(db *gorm.DB) error {
	err := db.Create(&c).Error
	err = db.Where("id = ?", c.ID).First(&c).Error
	return err
}
